package picobot.tests.students;

import picobot.interfaces.core.IMap;
import picobot.interfaces.core.IMapBuilder;
import picobot.tests.Bootstrap;
import junit.framework.TestCase;

/** This class tests the essential functionalities of IMapBuilder */
public class PublicTestMapBuilder extends TestCase {

  /** This method tests a programmatically built map */
  public void testA() {
    
    IMapBuilder mb = Bootstrap.f().createMapBuilder();
    
    mb.placeWall(0,0);
    mb.placeWall(1,0);
    mb.placeWall(2,0);
    mb.placeWall(0,1);
    mb.placeWall(2,1);
    mb.placeWall(0,2);
    mb.placeWall(1,2);
    mb.placeWall(2,2);
    
    System.out.println(mb.getCurrentMap().toString());
    assertEquals(
         "###\n"
        +"# #\n"
        +"###\n",
        mb.getCurrentMap().toString());

    assertEquals(
        3, mb.getCurrentMap().getHeight());

    assertEquals(
        3, mb.getCurrentMap().getWidth());

    assertEquals(
        8, mb.getCurrentMap().getNumberOfWalls());

  }

  /** This method tests a map parser */
  public void testB() {

    IMapBuilder mb = Bootstrap.f().createMapBuilder();
    
    String mapString =          
       "#####\n"
      +"# # #\n"
      +"#   #\n"
      +"#   #\n"
      +"#####\n";
    mb.parseMap(mapString);
    
    IMap map = mb.getCurrentMap();
    
    System.out.println(map);
    assertEquals(mapString, map.toString());
  }

}
